package com.yida.gwj.scene.expend.controller;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yida.common.core.utils.poi.ExcelUtil;
import com.yida.common.core.web.controller.BaseController;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.common.log.annotation.Log;
import com.yida.common.log.enums.BusinessType;
import com.yida.common.security.annotation.RequiresPermissions;
import com.yida.gwj.scene.expend.domain.GwjSceneExpendBusinessDetail;
import com.yida.gwj.scene.expend.service.IGwjSceneExpendBusinessDetailService;

/**
 * 线下支出详情Controller
 * 
 * @author hmh
 * @date 2023-08-14
 */
@RestController
@RequestMapping("/detail")
public class GwjSceneExpendBusinessDetailController extends BaseController {
    @Autowired
    private IGwjSceneExpendBusinessDetailService gwjSceneExpendBusinessDetailService;

    /**
     * 查询线下支出详情列表
     */
    @RequiresPermissions("gwj:scene:expend:detail:list")
    @GetMapping("/list")
    public TableDataInfo list(GwjSceneExpendBusinessDetail gwjSceneExpendBusinessDetail) {
        startPage();
        List<GwjSceneExpendBusinessDetail> list = gwjSceneExpendBusinessDetailService.selectGwjSceneExpendBusinessDetailList(gwjSceneExpendBusinessDetail);
        return getDataTable(list);
    }

    /**
     * 导出线下支出详情列表
     */
    @RequiresPermissions("gwj:scene:expend:detail:export")
    @Log(title = "线下支出详情", businessType = BusinessType.EXPORT, systemName = "gwj")
    @PostMapping("/export")
    public void export(HttpServletResponse response, GwjSceneExpendBusinessDetail gwjSceneExpendBusinessDetail) {
        List<GwjSceneExpendBusinessDetail> list = gwjSceneExpendBusinessDetailService.selectGwjSceneExpendBusinessDetailList(gwjSceneExpendBusinessDetail);
        ExcelUtil<GwjSceneExpendBusinessDetail> util = new ExcelUtil<GwjSceneExpendBusinessDetail>(GwjSceneExpendBusinessDetail.class);
        util.exportExcel(response, list, "线下支出详情数据");
    }

    /**
     * 获取线下支出详情详细信息
     */
    @RequiresPermissions("gwj:scene:expend:detail:query")
    @GetMapping(value = "/{detailId}")
    public AjaxResult getInfo(@PathVariable("detailId") Long detailId) {
        return AjaxResult.success(gwjSceneExpendBusinessDetailService.selectGwjSceneExpendBusinessDetailByDetailId(detailId));
    }

    /**
     * 新增线下支出详情
     */
    @RequiresPermissions("gwj:scene:expend:detail:add")
    @Log(title = "线下支出详情", businessType = BusinessType.INSERT, systemName = "gwj")
    @PostMapping
    public AjaxResult add(@RequestBody GwjSceneExpendBusinessDetail gwjSceneExpendBusinessDetail) {
        return toAjax(gwjSceneExpendBusinessDetailService.insertGwjSceneExpendBusinessDetail(gwjSceneExpendBusinessDetail));
    }

    /**
     * 修改线下支出详情
     */
    @RequiresPermissions("gwj:scene:expend:detail:edit")
    @Log(title = "线下支出详情", businessType = BusinessType.UPDATE, systemName = "gwj")
    @PutMapping
    public AjaxResult edit(@RequestBody GwjSceneExpendBusinessDetail gwjSceneExpendBusinessDetail) {
        return toAjax(gwjSceneExpendBusinessDetailService.updateGwjSceneExpendBusinessDetail(gwjSceneExpendBusinessDetail));
    }

    /**
     * 删除线下支出详情
     */
    @RequiresPermissions("gwj:scene:expend:detail:remove")
    @Log(title = "线下支出详情", businessType = BusinessType.DELETE, systemName = "gwj")
    @DeleteMapping("/{detailIds}")
    public AjaxResult remove(@PathVariable Long[] detailIds) {
        return toAjax(gwjSceneExpendBusinessDetailService.deleteGwjSceneExpendBusinessDetailByDetailIds(detailIds));
    }
}
